package com.cskaoyan.service;

import com.cskaoyan.bean.Admin;
import com.cskaoyan.bean.AdminExample;
import com.cskaoyan.mapper.AdminMapper;
import com.cskaoyan.vo.AdminVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2021/4/9 - 21:30
 */
@Service
public class AdminServiceImpl implements  AdminService {


    @Autowired
    AdminMapper adminMapper;
    @Override
    public AdminVo query(Integer page, Integer limit, String sort, String order) {

        PageHelper.startPage(page,limit);

        AdminExample adminExample = new AdminExample();
        List<Admin> admins = adminMapper.selectByExample(adminExample);

        PageInfo<Admin> adminPageInfo = new PageInfo<>(admins);
        long total = adminPageInfo.getTotal();

        AdminVo adminVo = new AdminVo();
        adminVo.setItems(admins);
        adminVo.setTotal(total);

        return adminVo;
    }
}
